package thread.basepackage.t7;

/**
 * Created by cuihao on 2017/11/29.
 */
public class Run {
    public static void main(String[] args) {
        try {
            final SynchronizedObject object = new SynchronizedObject();
            Thread thread1 = new Thread() {
                @Override
                public void run() {
                    System.out.println("线程1运行");
                    object.printString();
                }
            };
            thread1.setName("a");
            thread1.start();
            Thread.sleep(1000);

            Thread thread2 = new Thread() {
                @Override
                public void run() {
                    System.out.println("线程2运行");
                    System.out.println("thread1启动了，但是进入不了printString方法！纸打印了一个begin方法");
                    System.out.println("因为pringString方法被thread线程锁定，且永远suspend了！");
                    object.printString();
                }
            };
            thread2.start();

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
